<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.softwarerusher.datastructure.Cart" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>netshop/"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Book Store by www.softwarerusher.cn</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="wrap">
  <div class="header">
    <div class="logo"><a href="index.jsp"><img src="images/logo.gif" alt="" title="" border="0" /></a></div>
    <div id="menu">
      <ul>
        <li><a href="index.jsp">主页</a></li>
        <li><a href="about.jsp">关于我们</a></li>
        <li><a href="allcategory">百科全书</a></li>
        <li><a href="todayhot">今日特供</a></li>
        <li>
        <%if(session.getAttribute("login")==(null)||"false".equals(session.getAttribute("login"))){ %>
        <a href="myaccount.jsp">
        <%}else{ %>
        <a href="myaccountlogin.jsp">
        <%} %>
        我的账户
        </a></li>
        <li><a href="register.jsp">注册账户</a></li>
        <!--<li><a href="details.jsp">价格</a></li>-->
        <li><a href="contact.jsp">联系我们</a></li>
      </ul>
    </div>
  </div>
  <div class="center_content">
    <div class="left_content">
      <div class="title"><span class="title_icon"><img src="images/bullet1.gif" alt="" title="" /></span>我的购物车</div>
      <div class="feat_prod_box_details">
        <table class="cart_table">
          <tr class="cart_title">
            <td>摘图</td>
            <td>书名</td>
            <td>单价</td>
            <td>数量</td>
            <td>总价</td>
          </tr>
          <%List<Cart> cart = (List<Cart>)session.getAttribute("cart"); %>
          <%double sum = 0; %>
          <%for(int i = 0 ; i<cart.size() ; i++) {%>
          <tr>
            <td><a href="details?bookisbn=<%=cart.get(i).getBook().getBookIsbn() %>"><img src="<%=cart.get(i).getBook().getBookPic() %>" alt="" title="" border="0" class="cart_thumb1" /></a></td>
            <td><%=cart.get(i).getBook().getBookName() %></td>
            <td><%=cart.get(i).getBook().getBookPrice() %>元</td>
            <td><%=cart.get(i).getNum() %></td>
            <%if(String.valueOf(cart.get(i).getBook().getBookPrice() * cart.get(i).getNum()).length()<5){ %>
            <td><%=cart.get(i).getBook().getBookPrice() * cart.get(i).getNum() %>元</td>
            <%}else{ %>
            <td><%=( String.valueOf(cart.get(i).getBook().getBookPrice() * cart.get(i).getNum()).substring(0,5) ) %>元</td>
            <%} %>
            <%sum+=cart.get(i).getBook().getBookPrice() * cart.get(i).getNum(); %>
          </tr>
          <%} %>
          <tr>
            <td colspan="4" class="cart_total"><span class="red">发货总计:</span></td>
            <%if(String.valueOf(sum).length()<5){ %>
            <td><%=sum %>元</td>
            <%}else{ %>
            <td> <%=((String.valueOf(sum)).substring(0,5)  )  %>元</td>
            <%} %>
          </tr>
          <tr>
            <td colspan="4" class="cart_total"><span class="red">折扣:</span></td>
            <td> <%=session.getAttribute("discountRate") %></td>
          </tr>
          <tr>
            <td colspan="4" class="cart_total"><span class="red">邮费:</span></td>
            <td> 0</td>
          </tr>
          <tr>
            <td colspan="4" class="cart_total"><span class="red">总额:</span></td>
            <% sum = sum * (Double)session.getAttribute("discountRate");%>
            <%if(String.valueOf(sum).length()<5){ %>
            <td><%=sum %>元</td>
            <%}else{ %>
            <td> <%=((String.valueOf(sum)).substring(0,5)  )  %>元</td>
            <%} %>
          </tr>
        </table>
        <a href="allcategory" class="continue">&lt; 继续购书</a> <a href="checkoutdetails.jsp" class="checkout">订单结账&gt;</a> </div>
      <div class="clear"></div>
    </div>
    <!--end of left content-->
    <div class="right_content">

        <jsp:include page="cartview.jsp" /> 
      <div class="title"><span class="title_icon"><img src="images/bullet3.gif" alt="" title="" /></span>rush一下，你就知道</div>
      <div class="search">
        <form name ="search_now" action = "netshop/search" method= "post">
        <input type = "text" value = "斗破苍穹" name ="searchcontext" style="width:230px;height:20px;"/>
        <a class = "more"  href="javascript:document.search_now.submit()" ><img src="images/search_now.jpg" alt="" title="" border="0"/></a>
        </form>
        <p></p><p></p><p></p><p></p>
      </div>
      <jsp:include page="todayhot.jsp" /> 
      <jsp:include page="categorybox.jsp" />
    </div>
    <!--end of right content-->
    <div class="clear"></div>
  </div>
  <!--end of center content-->
  <div class="footer">
    <div class="left_footer"><img src="images/footer_logo.gif" alt="" title="" /><br />
      <a href="http://www.softwarerusher.cn">www.softwarerusher.cn</a></div>
    <div class="right_footer"> <a href="http://www.softwarerusher.cn">主页</a> <a href="about.jsp">关于我们</a> <a href="http://www.softwarerusher.cn">售后服务</a> <a href="http://www.softwarerusher.cn">保密规则</a> <a href="contact.jsp">联系我们</a> </div>
  </div>
</div>
</body>
</html>
